//
//  ZTPanelWindow.m
//  ZHYYView
//
//  Created by MT-SW-005 on 2021/11/12.
//  Copyright © 2021 yuan zhang. All rights reserved.
//

#import "ZTPanelWindow.h"

@interface ZTPanelWindow ()
{
    NSWindow *ztWindow;
}
@end

@implementation ZTPanelWindow




- (IBAction)cancel:(id)sender {
    NSLog(@"cancel");
    [self hidePanel];
}


- (IBAction)ok:(id)sender {
    NSLog(@"ok");
    [self hidePanel];
}



- (void)windowDidLoad {
    [super windowDidLoad];
    
    // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
}


-(id)init{
    self =[super init];
    if (self) {
        self =[self initWithWindowNibName:@"ZTPanelWindow"];
    }
    return self;
}



-(void)showPanel:(NSWindow*)window{
    ztWindow =window;
    NSLog(@"========== window:%@",window);
    [ztWindow beginSheet:self.panel completionHandler:^(NSModalResponse returnCode) {
        //completionHandler
    }];
}


-(void)hidePanel{
    if (ztWindow) {
        [ztWindow endSheet:self.panel];
    }else{
        NSLog(@"no panel opened");
    }
    
}
@end
